package com.vitabuybuy.tv.ui.mine.adapter

import android.graphics.Color
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.library.common.base.BindRecycAdapter
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemPointRewardsBinding
import com.vitabuybuy.tv.dto.ActivityNode

class PointRewardsAdapter(val quantity: Int) :
    BindRecycAdapter<ItemPointRewardsBinding, ActivityNode>() {
    override fun onBindViewHolder(
        mBinding: ItemPointRewardsBinding,
        itemData: ActivityNode,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.pointQuantity.text = itemData.quantity.toString()
        if (quantity >= itemData.quantity) {
            mBinding.endView.setBackgroundColor(Color.parseColor("#E23225"))
        } else {
            mBinding.endView.setBackgroundColor(Color.parseColor("#FF9E97"))
        }
        when (position) {
            0 -> {
                mBinding.pointView2.visibility = View.VISIBLE
                mBinding.endView.visibility = View.VISIBLE
            }
            mData.size - 1 -> {
                mBinding.pointView2.visibility = View.INVISIBLE
                mBinding.endView.visibility = View.GONE
            }
            else -> {
                mBinding.pointView2.visibility = View.VISIBLE
                mBinding.endView.visibility = View.VISIBLE
            }
        }
    }

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_point_rewards
    }
}
